//app.js
import Dialog from '/vant/weapp/dialog/dialog';
import Toast from '/vant/weapp/toast/toast';

const user = require('./utils/user');

App({
  //onLaunch,onShow: options(path,query,scene,shareTicket,referrerInfo(appId,extraData))
  onLaunch: function(options){
    
  },
  onShow: function(options){

  },
  onHide: function(){

  },
  onError: function(msg){

  },
  //options(path,query,isEntryPage)
  onPageNotFound: function(options){

  },
  getLocation:function(params) {
    wx.getLocation({
      type: "gcj02",
      success (res) {
          console.log(res)
          return JSON.stringify({res});
      }
    })
  },
  getToken:function(){
    return wx.getStorageSync('userToekn');
  },
  setToken:function(data){
    return wx.setStorageSync('userToekn', data)
  },
  isLogin(callBack){
    if (this.data.hasUserInfo === false) {
      Dialog.confirm({
          title: '您还未登录',
          message: '请授权获取微信信息并登录',
        })
        .then(() => {
          // on confirm
          callBack()
        })
        .catch(() => {
          // on cancel
        });
    }
  },
  alertSuccess(msg){
    Toast.success(msg);
  },
  alertFail(msg){
    Toast.fail(msg);
  },
  // 全局数据
  globalData: {
    qqmap:{
      key:'EKNBZ-WNTKR-Q6SWC-WSQV6-YES6H-4PBNX'
    },
    token:"",
    hasUserInfo: false
  }
});